<?php

namespace Goods\Controller;
use Common\Controller\HomebaseController;

class SearchController extends HomebaseController {

	// 搜索商品
	public function index() {
	    $keyword = I('request.keyword/s','');		
		if (empty($keyword)) {
			$this -> error("关键词不能为空！请重新输入！");
		}
		$where=array("is_on_sale"=>1,"is_delete"=>"neq 3","goods_name"=>array('like',"%$keyword%"));
		$count = M('Goods')->where($where)->count();
		$page = $this->page($count, 12);
		$list = M('Goods')
		->where($where)
		->limit($page->firstRow , $page->listRows)
		->select();
		
		$this->assign('list', $list);
		$this->assign('keyword', $keyword);
		$this->assign('page', $page->show('Home'));
    	$this->display(":search");
	}
			
}
